package com.leo.springbootmultithreadbasic.buildthread.extendsthread;

import static java.lang.System.out;

/**
 *
 * <p><b>创建线程的方式一：继承Thread类</b></p>
 * <p>线程是一个子任务，CPU以不确定的方式或者说以随机的时间来调用线程中的run方法。</p>
 * <p>这提现了线程调用的随机性。</p>
 *
 * @author Leo
 * @version V1.0
 * @date 2021/10/28 10:29 PM
 */
public class Run {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        myThread.start();

        out.println("The main thread start to sleep!");
        Thread.sleep(5000);
        out.println("休眠 End");
    }

}

/**
 * 内部类:自定义的Thread
 */
class MyThread extends Thread {
    @Override
    public void run() {
        out.println("The sub thread start executing run() method!");
    }
}
